package com.zfy.tingshu.album.mapper;

import com.zfy.tingshu.model.album.AlbumInfo;
import com.zfy.tingshu.vo.album.AlbumInfoVo;
import com.zfy.tingshu.vo.album.AlbumListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zfy.tingshu.vo.album.AlbumStatVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.RequestParam;

@Mapper
public interface AlbumInfoMapper extends BaseMapper<AlbumInfo> {


    IPage<AlbumListVo> findUserAlbumPage(IPage<AlbumListVo> page, @RequestParam("userId") Long userId);

    AlbumInfo getAlbumInfo(@RequestParam("albumId") Long albumId);

    AlbumStatVo getAlbumStatVo(Long albumId);

    @Update("update album_stat\n" +
            "        set stat_num = stat_num + #{count}\n" +
            "where album_id = #{albumId} and stat_type = #{statType}")
    void updateStat(@Param("albumId") Long albumId,@Param("statType") String statType,@Param("count") Integer count);
}
